﻿
package bsplib.q3bsp;
import flash.utils.ByteArray;
import org.flashdevelop.utils.FlashConnect;

import flash.Vector;

class Q3VisData 
{
    public static inline var DIR_INDEX : UInt = 16;
    
    public var rowNum : Int;
    public var rowSize : Int;
    public var visMat : Vector<Bool>;
    
    public function new( data : ByteArray ) 
    {
        rowNum = data.readInt();
        rowSize = data.readInt();
        
        visMat = new Vector<Bool>(rowNum * rowSize * 8);
        
        var visMatIdx = 0;
        for ( i in 0...(rowNum * rowSize) ) {
            var val = data.readUnsignedByte();
            for ( j in 0...8 ) {
                visMat[visMatIdx++] = (val & (1 << j)) != 0;
            }
        }
        
        rowSize *= 8;
    }
    
}